package com.ad_hccm.service.impl.Appendix;

import com.ad_hccm.dao.Appendix.ExitDao;
import com.ad_hccm.domain.Appendix.Exit;
import com.ad_hccm.service.Appendix.ExitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * TODO 退出(脱落)
 */
@Service
public class ExitServiceImpl implements ExitService {
    @Autowired
    private ExitDao dao;

    @Override
    public boolean save(Exit domain) {
        return dao.save(domain);
    }

    @Override
    public boolean update(Exit domain) {
        if(domain.getReason()==0){
            domain.setSex(false);
            domain.setComplications(false);
            domain.setTransfer(false);
            domain.setAe(false);
        }else if(domain.getReason()==1){
            domain.setPoorTherapeuticEffect(false);
            domain.setUnbearable(false);
            domain.setEconomicReason(false);
            domain.setRefusalExplanation(false);
            domain.setLostFollow_up(false);
        }
        return dao.update(domain);
    }

    @Override
    public Exit getById(String id) {
        return dao.getById(id);
    }

    @Override
    public List<Exit> getAll() {
        return dao.getAll();
    }
    @Override
    public boolean delete(String id){return dao.delete(id);}
}
